package com.jyniubi.base.exception;

import com.jyniubi.base.result.ResponseEnum;
import lombok.extern.slf4j.Slf4j;

/**
 * @author jyzhang
 * 断言类
 */

@Slf4j
public class Assert {
    // 对象为空抛自定义异常类
    public static void assertObjectIsNull(Object obj, ResponseEnum responseEnum){
        if (obj == null){
            log.error("assert {} is null",obj);
            throw new  BussinessException(responseEnum);
        }
    }
    //boolean类型为false抛自定义异常类
    public static void assertNotTrue(Boolean flag,ResponseEnum responseEnum){
        if (!flag){
            log.error("assert is false");
            throw new BussinessException(responseEnum);
        }
    }

    //boolean类型为true抛自定义异常类
    public static void assertTrue(Boolean flag,ResponseEnum responseEnum){
        if (flag){
            log.error("assert is true");
            throw new BussinessException(responseEnum);
        }
    }
}
